1. Technical Field
Embodiments described herein relate to a time synchronization system for communication between a master and plural slaves.
2. Related Art
Systems are known in which a master and plural slaves are connected by a network and data communications are performed between them over the network. Each of the master and the slaves incorporates an internal clock therein, and it is important to establish synchronization between the master and each slave. The IEEE 1588 protocol (hereinafter referred to as “1588 protocol”) is known as a protocol for such time synchronization.
In the 1588 protocol, the internal clocks of the master and each slave are synchronized with each other by exchanging packets which contain time stamp information generated based on the internal clock of each apparatus and calculating a network delay and a time difference. JP-A-2010-4321 discloses time synchronization systems utilizing the 1588 protocol.
In the 1588 protocol, in general, each slave sends, to the master, packets containing a transmission time that is calculated based on its own internal clock. The master determines a reception time based on its own internal clock. The difference between the transmission time and the reception time is equal to the sum of a time difference between the two internal clocks and a network delay. The same applies to a case that the master sends time synchronization packets to each slave. In this manner, the internal clocks of the master and each slave are synchronized with each other by calculating a time difference between the two internal clocks and a network delay.
FIG. 5 shows a related-art time synchronization system 101. The time synchronization system 101 includes a master 102, four slaves (a first slave 103-1 to a fourth slave 103-4 (generically referred to as a slave(s) 103), and a relay 104. Packet communications for purposes other than time synchronization are mainly performed between the master 102 and each slave 103, though packet communications for time synchronization are also performed.
The relay 104 is a network relay for relaying communications between the master 102 and each slave 103 and is what is called a layer 2 switch (denoted by L2SW in FIG. 5) may be used as the relay 104. The relay 104 determines communication destinations based on IP addresses that are set in packets, and thereby realizes packet communications between the master 102 and the slaves 103.
When packets are communicated from plural slaves 103 to the master 102, the relay 104 is loaded heavily because of concentration of packets. As shown in FIG. 6, the layer 2 switch serving as the relay 104 has buffers 105 for respective IP addresses and sends out packets to the master 102 in order of their inputs to the buffers 105.
FIG. 6 shows a state (first communication example) that ordinary packets (not for time synchronization) P1, P2, and P3 and a packet 1588 (for time synchronization) are being transmitted from the four slaves 103 to the master 102 via the relay 104. The ordinary packets P1-P3 and the time synchronization packet 1588 contain an IP address of the master 102 as a destination IP address.
In the example of FIG. 6, the time synchronization packet 1588 is given highest priority and hence is output first from the buffers 105 toward the master 102. Therefore, the time synchronization packet 1588 can be output with a shortest waiting time T1 without being affected by the other packets P1-P3.
FIG. 7 shows a second communication example. In this example, although time synchronization packet 1588 is given highest priority, an ordinary packet P1 reached the buffers 105 before the time synchronization packet 1588 and is already being output from the buffers 105. Since the output of the ordinary packet P1 cannot be suspended halfway, the time synchronization packet 1588 should wait until completion of the output of the ordinary packet P1. The time synchronization packet 1588 is output after a lapse of a waiting time T2.
FIG. 8 shows a third communication example. In this example, ordinary packets P1-P3 are higher in priority than a time synchronization packet 1588. The time synchronization packet 1588 is sent to the master 102 after completion of sending of the ordinary packets P1-P3. In this example, the time synchronization packet 1588 is sent to the master 102 after a lapse of a longest waiting time T3.
A time synchronization packet is a packet for establishing time synchronization between the master 102 and each slave 103, and time synchronization cannot be established accurately if the timing of arrival of a time synchronization packet varies. That is, the accuracy of time synchronization deteriorates if the network delay from sending of a time synchronization packet by a slave 103 to its reception by the master 102 varies.
In the example of FIG. 6 in which the time synchronization packet 1588 is output first, and thus is not affected by the other ordinary packets P1-P3. Hence, the network delay can be made equal to the shortest waiting time T1. Since the waiting time T1 is not affected by the other ordinary packets P1-P3, the master 102 can establish time synchronization accurately based on the received time synchronization packet 1588.
On the other hand, in the example of FIG. 7 in which output of the ordinary packet P1 has already started though the time synchronization packet 1588 is given highest priority. Output of the time synchronization packet 1588 is started after completion of the output of the ordinary packet P1. In this example, the waiting time T2 varies depending on to what extent the output of the ordinary packet P1 has progressed at the time of arrival of the time synchronization packet 1588 at the relay 104.
For example, where the communication rate is 100 Mbps and the packet length of the ordinary packet P1 is 1 Kbytes, the waiting time T2 measures a maximum of 80 us. The waiting time T2 varies up to 80 us depending on the size of the ordinary packet P1 and to what extent its output has progressed. Thus, the waiting time T2 cannot be predicted.
In the example of FIG. 8 in which the ordinary packets P1-P3 are higher in priority than the time synchronization packet 1588, the time synchronization packet 1588 is output after completion of output of the ordinary packets P1-P3. The packet lengths of the ordinary packets P1-P3 are variable, and it cannot be predicted to what extent the output of the ordinary packets P1-P3 has progressed. Therefore, the waiting time T3 varies to a large extent.
As mentioned above, the master 102 and each slave 103 establish time synchronization based on a time synchronization packet. Therefore, if the waiting time varies as in the examples of FIGS. 7 and 8, the network delay varies and the accuracy of time synchronization deteriorates. In particular, packets are communicated from many slaves 103 to the master 102, the network delay varies to a large extent because of the concentration of packets.